#include "PDTWhile.h"
#include "PDTCodeGraph.h"


void PDTWhile::setCondition(PDTExpBool & condition){
	writers[0]=&condition;
	condition.addReader(this);

	addChild(&condition);
	condition.addParent(this);
}

void PDTWhile::setLoopStatement(PDTStatement & loopStatement){
	writers[1]=&loopStatement;
	loopStatement.addReader(this);

	addChild(&loopStatement);
	loopStatement.addParent(this);
}

PDTExpBool* PDTWhile::getCondition(){
	return dynamic_cast<PDTExpBool *>(writers[0]);
}

PDTStatement * PDTWhile::getLoopStatement(){
	return dynamic_cast<PDTStatement *>(writers[1]);

}

PDTWhile::PDTWhile(PDTCodeGraph & CG,PDTExpBool & condition,PDTStatement & loopStatement):PDTStatement(CG){
	addWriter(&condition);
	condition.addReader(this);
	addChild(&condition);
	condition.addParent(this);

	addWriter(&loopStatement);
	loopStatement.addReader(this);
	addChild(&loopStatement);
	loopStatement.addParent(this);
}
